package com.yumingjiang.expand.postprocessor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        // 在初始化之前对bean进行处理
        log.info("Before initialization of bean: " + beanName);
        return bean; // 返回bean实例，可以返回同一个实例或替换为另一个实例
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        // 在初始化之后对bean进行处理
        log.info("After initialization of bean: " + beanName);
        return bean; // 返回bean实例，可以返回同一个实例或替换为另一个实例
    }
}